<?php
require_once dirname(dirname(__FILE__)) . '/config/config.php';
require_once DOCUMENT_ROOT . DIR_SHARED_DAO . "dao_combo.php";
require_once DOCUMENT_ROOT . DIR_SHARED_LIBRARIES . 'lib_sql_convert.php';


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of api_security
 *
 * @author Thien
 */
class api_combos {
    
    public static function save_combo($combo_id, $name, $description, $price, $image) {
        $dao_combo = new dao_combo();
        return $dao_combo->save($combo_id, $name, $description, $price, $image);
    }
    
    public static function delete_combo($combo_id) {
        $dao_combo = new dao_combo();
        return $dao_combo->delete($combo_id);
    }
    
    public static function get_combo_by_id($combo_id) {
        $dao_combo = new dao_combo();
        return $dao_combo->get_by_id($combo_id);
    }
    
    public static function get_all_combos() {
        $dao_combo = new dao_combo();
        return $dao_combo->get_all();
    }
    
    public static function get_all_combos_with_now_showing() {
        $dao_combo = new dao_combo();
        $status_id = 2; //for now showing
        return $dao_combo->get_all_by_status_id($status_id);
    }
    
    public static function get_all_combos_with_comming_soon() {
        $dao_combo = new dao_combo();
        $status_id = 1; //for comming soon
        return $dao_combo->get_all_by_status_id($status_id);
    }
    
    public static function get_all_combo_statuses() {
        $dao_combo_status = new dao_combo_status();
        return $dao_combo_status->get_all();
    }
    
    public static function get_default_combo_statuses() {
        $dao_combo_status = new dao_combo_status();
        $status = $dao_combo_status->get_first();
        if (!empty($status['name'])) {
            return $status['name'];
        }
        return "";
    }
    
    public static function get_status_id_from_name($name) {
        $dao_combo_status = new dao_combo_status();
        $status = $dao_combo_status->get_id_by_name($name);
        return $status['id'];
    }
    
    public static function validate_combo_fields($name, $description, $price, $image) {
        $error_show = "";
        if (empty($name)) {
            $error_show .= "<li>Please fill Name.</li>";
        }
        if (empty($description)) {
            $error_show .= "<li>Please fill Description.</li>";
        }
        if (empty($price)) {
            $error_show .= "<li>Please fill Price.</li>";
        }
        if (empty($image)) {
            $error_show .= "<li>Please fill Image.</li>";
        }
        return $error_show;
    }
    
}
